#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <easyx.h>
#include <math.h>
using namespace std;

#define PI 3.14

void fivestar(int x, int y, int r, double delta);
int main()
{

	initgraph(800, 600);
	setbkcolor(RGB(164, 225, 202));
	cleardevice();

	setorigin(400, 300);
	setaspectratio(1, -1);

	setfillcolor(WHITE);
	//circle(-400, 0, 50);
	//int x = 0;
	//int y = 0;
	//for (x = -400; x <= 400; x += 5)
	//{
	//	cleardevice();
	//	solidcircle(x, y, 50);
	//	Sleep(40);
	//}

	setpolyfillmode(WINDING);

	int x = 0;
	int y = 0;
	int dx = 5;
	for (x = -400; x <= 400;)
    {
		cleardevice();
		fivestar(x, y, 50, PI / 2);
		Sleep(40);

		x += dx;
		if (x == 400 || x == -400)
		{
			dx = -dx;
		}
    }

	getchar();
	closegraph();
	return 0;
}


void fivestar(int x, int y, int r, double start)
{
	double delta = 2 * PI / 5;
	POINT points[5];
	for (int i = 0; i < 5; i++)
	{
		points[i].x = cos(start + i * delta * 2) * r + x;
		points[i].y = sin(start + i * delta * 2) * r + y;
	}
	solidpolygon(points, 5);
}